import {
  PrimaryGeneratedColumn,
  Column,
  Entity,
  ManyToOne,
  JoinColumn,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';
import { CarModel } from '../car_model/car_model.entity';
@Entity('car_info')
export class CarInfo {
  @PrimaryGeneratedColumn({
    comment: 'car id',
  })
  car_id: number;

  @Column({
    comment: '型号id',
  })
  model_id: number;

  @Column({
    comment: '名称',
  })
  name: string;

  @Column({
    comment: '车型描述',
  })
  content: string;

  @Column({
    comment: '车型',
  })
  car_model: string;

  @Column({
    comment: '排量',
  })
  displacement: string;

  @Column({
    comment: '座位数',
  })
  seating: number;

  @Column({
    comment: '驱动方式 0.前驱 1.后驱 2.四驱',
  })
  drive: string;

  @Column({
    comment: '能源',
  })
  energy: string;

  @Column({
    comment: '价格描述',
  })
  price: string;

  @Column({
    comment: '长度（mm）',
  })
  length: number;

  @Column({
    comment: '宽度（mm）',
  })
  width: number;

  @Column({
    comment: '油箱容积L',
  })
  tank: number;

  @Column({
    comment: '气缸数（个）',
  })
  cylinder: number;

  @Column({
    comment: '气缸数（个）',
  })
  tag: number;

  @Column({
    comment: '上市时间',
  })
  list_time: string;

  @Column({
    comment: '创建时间',
    type: 'timestamp',
    readonly: true,
    update: false,
  })
  @CreateDateColumn()
  create_time: number;

  @Column({
    comment: '修改时间',
    type: 'timestamp',
    readonly: true,
  })
  @UpdateDateColumn()
  update_time: number;

  @ManyToOne(() => CarModel, (CarModel) => CarModel.name, { eager: true })
  @JoinColumn({ name: 'model_id' })
  CarModel: CarModel;
}
